package mylibrary.thread.produce_consume.another;

public class Restaurant {

	private boolean mealReady = false;
	
	public synchronized void cook() {
		while(mealReady == true) {
			try {
				wait();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		mealReady = true;
		System.out.println("Meal is ready!");
		notifyAll();
	}
	
	public synchronized void sendMeal() {
		while(mealReady == false) {
			try {
				wait();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		mealReady = false;
		System.out.println("Meal is sent!");
		notifyAll();
	}
	
	
}
